package net.bsayiner.sadeceHaber.Activities;

import net.bsayiner.sadeceHaber.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SlidingHeaderAdapter extends BaseAdapter {

	private String[] newsList;
	private final Context context;
	private int selectedItemPosition = 0;

	public SlidingHeaderAdapter(Context context) {
		this.context = context;
		newsList = context.getResources().getStringArray(R.array.news_list);
	}

	public int getCount() {
		return newsList.length;
	}

	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return 0;
	}

	public int getSelectedItemPosition() {
		return selectedItemPosition;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.sliding_header_layout, null);
		TextView title = (TextView) retval.findViewById(R.id.title);
		title.setText(newsList[position]);
		if (position == getSelectedItemPosition()) {
			retval.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.listview_selected_background));
		} else {
			retval.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.listview_background));
		}

		return retval;
	}

	public void setSelectedItemPosition(int selectedItemPosition) {
		this.selectedItemPosition = selectedItemPosition;
	}

}